package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDTO;
import com.zzyl.dto.NursingLevelPageDto;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/nursingLevel")
@Api(tags = "护理等级相关接口")
@Slf4j
public class NursingLevelController extends BaseController{
    @Autowired
    private NursingLevelService nursingLevelService;
    @GetMapping("/listAll")
    @ApiOperation("查询所有护理等级")
    public ResponseResult selectAll(){
      List<NursingLevelVO> nursingLevelVOList = nursingLevelService.selectAll();
        return success(nursingLevelVOList);
    }

    @GetMapping("/listByPage")
    @ApiOperation("分页条件查询")
    public ResponseResult pageCondition(NursingLevelPageDto nursingLevelPageDto){
      PageResponse<NursingLevelVO> pageResponse = nursingLevelService.pageCondition(nursingLevelPageDto);
    return success(pageResponse);
    }

    @PostMapping("/insert")
    @ApiOperation("新增护理等级")
    public ResponseResult insert(@RequestBody NursingLevelDTO nursingLevelDTO){
        nursingLevelService.insert(nursingLevelDTO);
        return success();
    }

    @GetMapping("/{id}")
    @ApiOperation("根据ID查询护理等级")
    public ResponseResult getById(@PathVariable Long id){
       NursingLevelVO nursingLevelVO =  nursingLevelService.getById(id);
        return success(nursingLevelVO);
    }
    @PutMapping("/update")
    @ApiOperation("修改护理等级")
    public ResponseResult update(@RequestBody NursingLevelDTO nursingLevelDTO){
        nursingLevelService.update(nursingLevelDTO);
        return success();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("删除护理等级")
    public ResponseResult delete(@PathVariable Long id){
        nursingLevelService.delete(id);
        return success();
    }


    @PutMapping("/{id}/status/{status}")
    @ApiOperation("修改护理等级状态")
    public ResponseResult changeStatus(@PathVariable Long id ,@PathVariable Integer status){
        nursingLevelService.changeStatus(id,status);
        return  success();
    }
}
